﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Threading.Tasks;

namespace netCoreStudy.Entities.Base
{
	public interface IBaseService<T> where T : BaseEntity
	{
		/// <summary>
		/// 创建
		/// </summary>
		/// <param name="model"></param>
		void Add(T model);

		/// <summary>
		/// 批量 创建
		/// </summary>
		/// <param name="models"></param>
		void AddRange(List<T> models);

		/// <summary>
		/// 修改
		/// </summary>
		/// <param name="model"></param>
		void Update(T model);

		/// <summary>
		/// 假删
		/// </summary>
		/// <param name="model"></param> 
		void Remove(T model);

		/// <summary>
		/// 真删 
		/// </summary>
		/// <param name="model"></param>  
		void TrueRemove(T model);

		/// <summary>
		/// 保存 
		/// </summary>
		/// <returns></returns>
		Task<bool> SaveAsync();

		/// <summary>
		/// 根据id判断是否存在(异部方法)
		/// </summary>
		/// <param name="id"></param>
		/// <returns></returns>
		Task<bool> ExistByIdAsync(long id);

		/// <summary>
		/// 根据id 查询 是否存在 同步方法
		/// 因为 validator 验证的时候 不能用异步方法 故用同步方法代替
		/// </summary>
		/// <param name="id">主键</param>
		/// <returns></returns>
		bool ExistById(long id);

		/// <summary>
		/// 根据 id 获取一个
		/// </summary>
		/// <param name="id"></param>
		/// <returns></returns>
		Task<T> GetOneByIdAsync(long id);

		/// <summary>
		/// 获取多个(列表)
		/// </summary>
		/// <returns></returns>
		IQueryable<T> GetAll();
		
		/// <summary>
		/// 获取多个 单独
		/// </summary>
		/// <returns></returns>
		IQueryable<T> GetAllSingle();
		/// <summary>
		/// 获取多个(列表) 根据 id[] 列表 
		/// </summary>
		/// <returns></returns>
		Task<List<T>> GetAllByIdsAsync(long[] ids);

		/// <summary>
		/// 获取 分页 列表
		/// </summary>
		/// <param name="baseParameter"></param>
		/// <returns></returns>
		Task<PageList<T>> GetPages(BaseParameter baseParameter
		);

		/// <summary>
		/// 获取 分页 列表 并转换为dto res
		/// </summary>
		/// <param name="baseParameter"></param>
		/// <returns></returns>
		Task<ResMsg<PageRes<TDto>>> GetPagesDto<TDto>(
			BaseParameter baseParameter);
	}
}